<?php

/**
 * Sets the body-tag class attribute.
 *
 * Adds 'sidebar-left', 'sidebar-right' or 'sidebars' and 'front' classes as needed.
 */
function phptemplate_body_class($left, $right) {
  if ($left != '' && $right != '') {
    $class = 'sidebars';
  }
  else {
    if ($left != '') {
      $class = 'sidebar-left';
    }
    if ($right != '') {
      $class = 'sidebar-right';
    }
  }
  
  if (drupal_is_front_page()) {
  	$class .= ' front';
  }

  if (isset($class)) {
    print ' class="'. $class .'"';
  }
}

/**
 * Generates IE CSS links .
 */
function phptemplate_get_ie_styles() {
  $iecss = '<link type="text/css" rel="stylesheet" media="all" href="'. base_path() . path_to_theme() .'/css/ie.css" />';
  
  return $iecss;
}

function phptemplate_preprocess_page(&$vars) {
  // Generate menu tree from source of primary links.
  $vars['primary_links_tree'] = menu_tree(variable_get('menu_primary_links_source', 'primary-links'));
  
  // Is front?
  $vars['is_front'] = drupal_is_front_page();
  
  // Front image
  if ($vars['is_front']) {
    $vars['front_image'] = l(theme('image', path_to_theme() .'/images/front.jpg'), 'tour', array('html' => TRUE));;
  }
  
  // Set page title to 'LYSSNA' in music node.
  if ($vars['node']) {
    if ($vars['node']->type == 'track') {
      $vars['title'] = 'LYSSNA';
      $vars['head_title'] = $vars['title'] . ' | ' . $vars['site_name'];
    }
  }
  
  // Set page title to 'PRESS' in press node.
  if ($vars['node']) {
    if ($vars['node']->type == 'press') {
      $vars['title'] = 'PRESS';
      $vars['head_title'] = $vars['title'] . ' | ' . $vars['site_name'];
    }
  }
}


